//
//  SYBiaoTiView.m
//  SanYiTeaching
//
//  Created by 郑浩然 on 2019/4/19.
//  Copyright © 2019年 SanYi. All rights reserved.
//

#import "SYBiaoTiView.h"

@interface SYBiaoTiView ()

@property (strong, nonatomic) UIView *jinXingView;//进行中
@property (strong, nonatomic) UIView *wanchengView;//已完成


@end


@implementation SYBiaoTiView

- (instancetype)init {
    self = [super init];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
        [self initSubView];
    }
    return self;
}

- (void)initSubView {
    [self addSubview:self.jinXingView];
    [self addSubview:self.wanchengView];
    CGFloat paing = 14;
    [self.jinXingView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.equalTo(self);
        make.left.equalTo(self.mas_left).offset(paing);
        make.right.equalTo(self.mas_right).offset(-paing);
    }];
    [self.wanchengView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.equalTo(self);
        make.left.equalTo(self.mas_left).offset(paing);
        make.right.equalTo(self.mas_right).offset(-paing);
    }];
    
    NSArray *xiaoArr = @[@"工号",@"姓名",@"性别",@"手机号",@"加入日期",@"最近状态",@"查看",@"移出"];
    //CGFloat whit = (865*fw)/8;
    UILabel *contLab = nil;
    for (NSInteger i = 0; i < xiaoArr.count; i++) {
        UILabel *title = [UILabel titleColour:TITLECOLOR
                                   titleFount:14
                                     pingfang:@"PingFang-SC-Medium"
                                    alignment:NSTextAlignmentCenter
                                    titleLine:1];
        title.text = xiaoArr[i];
        [self.jinXingView addSubview:title];
        if (i == 0) {
            contLab = title;
            [title mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(self.jinXingView.mas_left);
                make.top.equalTo(self.jinXingView.mas_top);
                make.width.equalTo(self.jinXingView).multipliedBy(0.125);
                make.height.mas_equalTo(40);
            }];
        } else {
            [title mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(contLab.mas_right);
                make.top.equalTo(self.jinXingView.mas_top);
                make.width.equalTo(self.jinXingView).multipliedBy(0.125);
                make.height.mas_equalTo(40);
            }];
            contLab = title;
        }
    }
    
    
    NSArray *wanArr = @[@"工号",@"姓名",@"性别",@"手机号",@"加入日期",@"最近状态",@"查看"];
//    CGFloat W  = (865*fw)/7;
    UILabel *contLab1 = nil;
    for (NSInteger i = 0; i < wanArr.count; i++) {
        UILabel *title = [UILabel titleColour:TITLECOLOR
                                   titleFount:14
                                     pingfang:@"PingFang-SC-Medium"
                                    alignment:NSTextAlignmentCenter
                                    titleLine:1];
        title.text = xiaoArr[i];
        [self.wanchengView addSubview:title];
        if (i == 0) {
            contLab1 = title;
            [title mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(self.wanchengView.mas_left);
                make.top.equalTo(self.wanchengView.mas_top);
                make.width.equalTo(self.wanchengView).multipliedBy(0.143);
                make.height.mas_equalTo(40);
            }];
        } else {
            [title mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(contLab1.mas_right);
                make.top.equalTo(self.wanchengView.mas_top);
                make.width.equalTo(self.wanchengView).multipliedBy(0.143);
                make.height.mas_equalTo(40);
            }];
            contLab1 = title;
        }
    }
    
}


- (void)setType:(SYBiaoTiViewType)type {
    if (type == SYBiaoTiViewTypeJinXing) {
        self.jinXingView.hidden = NO;
        self.wanchengView.hidden = YES;
    } else {
        self.jinXingView.hidden = YES;
        self.wanchengView.hidden = NO;
    }
}

- (UIView *)jinXingView {
    if (!_jinXingView) {
        _jinXingView = [[UIView alloc] init];
        _jinXingView.backgroundColor = [UIColor whiteColor];
    }
    return _jinXingView;
}

- (UIView *)wanchengView {
    if (!_wanchengView) {
        _wanchengView = [[UIView alloc] init];
        _wanchengView.backgroundColor = [UIColor whiteColor];
    }
    return _wanchengView;
}


@end
























